<template>
  <view class="content">
    <!-- 一 -->
    <view class="Task_information">
      <view class="box_a">
        <view class="box_color">
        </view>
        <view class="box_word">
          任务信息
        </view>
      </view>
      <view class="box_b">
        <view class="box_name">
          执行人：
        </view>
        <view class="box_name_a">
          <view class="head_word">
            <ms-dropdown-menu>
              <ms-dropdown-item @input="mileage" v-model="value" :list="All_name"></ms-dropdown-item>
            </ms-dropdown-menu>
          </view>
        </view>
      </view>
      <view class="box_b">
        <view class="box_name">
          限定完成时间：
        </view>
        <view class="box_name_b">
          <uni-datetime-picker type="date" :value="date" start="2020-6-15" end="2025-6-15" @change="dateChange">
          </uni-datetime-picker>
        </view>
      </view>
    </view>
    <!-- 二 -->
    <view class="Task_information">
      <view class="box_a">
        <view class="box_color">
        </view>
        <view class="box_word">
          任务内容
        </view>
      </view>
      <view class="uni-textarea">
        <textarea class="JTxtArea lg" placeholder-style="color:#999999" placeholder="请输入任务内容..." :maxlength="300"
          v-model="reason"></textarea>
      </view>
    </view>
    <!-- 三 -->
    <view class="Task_information">
      <view class="box_a">
        <view class="box_color">
        </view>
        <view class="box_word">
          任务附件
        </view>
      </view>
      <view class="upload" @click="upload">
        上传附件
      </view>
      <view class="btn_delete">
        删除
      </view>
      <view class="btn_upload">
        上传
      </view>
    </view>
    <view class="foot_btn">
      <view class="cancel">
        取消
      </view>
      <view class="release">
        发布
      </view>
    </view>
  </view>
</template>

<script>
  import msDropdownMenu from '@/components/ms-dropdown/dropdown-menu.vue'
  import msDropdownItem from '@/components/ms-dropdown/dropdown-item.vue'
  export default {
    components: {
      msDropdownMenu,
      msDropdownItem
    },
    data() {
      return {
        reason: '',
        date: '',
        value: 0,
        peopleid: '',
        Completion_time: '',
        All_name: [{
          text: '选择企业',
          value: 0
        }]
      };
    },
    onLoad() {
      this.getpeopleName()
    },
    methods: {
      getpeopleName() {
        this.$http.get('/upms/user/queryAllUsersByCustomerId/', {}).then(res => {
          console.log('people', res)
          if (res.code == '00000') {
            // console.log('设备状态数量统计', res.data)
            const list = []
            res.data.forEach((item, index) => {
              list.push({
                text: item.userName,
                id: item.id,
                value: index + 1
              })
            })
            list.unshift({
              text: '请选择执行人',
              value: 0
            })
            this.All_name = list
          }
        })
      },
      mileage(e) {
        this.value = e.value
        this.peopleid = e.id
        // console.log('enterprise_id',this.enterprise_id);
      },
      dateChange(e) {
        this.Completion_time = e
        // console.log('0000',this.startTime)
      },
      upload() {
        var REQUESTCODE = 1;
        var main = plus.android.runtimeMainActivity();
        var Intent = plus.android.importClass('android.content.Intent');
        var intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType('*/*'); //设置类型，任意类型
        //intent.setType("image/*");
        //intent.setType("audio/*"); //选择音频
        //intent.setType("video/*"); //选择视频 （mp4 3gp 是android支持的视频格式）
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        main.startActivityForResult(intent, REQUESTCODE);
        main.onActivityResult = function(requestCode, resultCode, data) {
          if (REQUESTCODE == requestCode) {
            var context = main;
            plus.android.importClass(data);
            // 获得文件路径
            var fileData = data.getData();
            var path = plus.android.invoke(fileData, 'getPath');
            console.log('path:' + path);
            // 判断文件类型
            // var resolver = context.getContentResolver();
            // var fileType = plus.android.invoke(resolver, 'getType', fileData);
            // console.log('fileType:' + fileType);
          }
        };
      }
    }
  }
</script>

<style lang="scss">
  .content {
    height: 100vh;
    background: #F7F7F7;
    overflow: hidden;
  }

  .Task_information {
    position: relative;
    width: 662rpx;
    margin: 20rpx auto;
    border-radius: 8rpx;
    padding: 20rpx;
    background-color: #FFFFFF;
  }

  .box_a {
    display: flex;
    align-items: center;
  }

  .box_color {
    width: 14rpx;
    height: 28rpx;
    margin-right: 12rpx;
    background: #4EA1FF;
    opacity: 1;
  }

  .box_word {
    font-size: 28rpx;
    font-family: Source Han Sans CN;
    font-weight: bold;
    color: #7A8AAA;
  }

  .box_b {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100rpx;
    font-size: 28rpx;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #94A5C7;
    border-bottom: 1rpx solid rgba(148, 165, 199, 0.1);
  }

  .box_b:last-child {
    border: none;
  }

  .box_name_a {
    width: 260rpx;
    height: 100%;
  }

  .box_name_b {
    display: flex;
    align-items: center;
    width: 200rpx;
    height: 80rpx;
  }

  .JTxtArea {
    background-color: #FFFFFF;
    border-radius: 5rpx;
    width: calc(100% - 16rpx);
    // box-sizing: border-box;
    padding: 12rpx 12rpx 15rpx;
    min-height: 60rpx;
    line-height: 40rpx;
    color: #000000;
    position: relative;

    &.sm {
      min-height: 30rpx;
    }

    &.lg {
      min-height: 200rpx;
    }

    &:after {
      content: attr(data-maxnum);
      position: absolute;
      right: 5rpx;
      bottom: 0rpx;
      font-size: 30rpx;
      color: #999999;
    }
  }

  .upload {
    font-size: 28rpx;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #94A5C7;
    margin-top: 40rpx;
  }

  .btn_delete {
    position: absolute;
    top: 20rpx;
    right: 150rpx;
    width: 90rpx;
    height: 36rpx;
    font-size: 24rpx;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #FFFFFF;
    background: #FF806C;
    opacity: 1;
    text-align: center;
    border-radius: 4rpx;
  }

  .btn_upload {
    position: absolute;
    top: 20rpx;
    right: 36rpx;
    width: 90rpx;
    height: 36rpx;
    font-size: 24rpx;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #FFFFFF;
    background: #4EA1FF;
    opacity: 1;
    text-align: center;
    border-radius: 4rpx;
  }

  .foot_btn {
    width: 702rpx;
    margin: 200rpx auto 0;
    display: flex;
    align-items: center;
    justify-content: space-around;
  }

  .cancel {
    width: 242rpx;
    height: 80rpx;
    line-height: 80rpx;
    font-size: 28rpx;
    text-align: center;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #4EA1FF;
    border: 1rpx solid #4EA1FF;
    opacity: 1;
    border-radius: 4rpx;
  }

  .release {
    width: 440rpx;
    height: 80rpx;
    line-height: 80rpx;
    font-size: 28rpx;
    text-align: center;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #FFFFFF;
    background: #4EA1FF;
    opacity: 1;
    border-radius: 4rpx;
  }
</style>
